const {
    Mysql
} = require('../../tools/index');
module.exports = async (ctx) => {
    let {
        currentPage,
        pageSize
    } = ctx.query;
    let sql = `SELECT * from video ORDER BY create_time DESC LIMIT ${(currentPage-1)*pageSize},${pageSize}`;
    let totalSql = `SELECT COUNT(*) as total from video`
    let list = await Mysql(sql);
    let total = await Mysql(totalSql);
    if (list) {
        ctx.state.data = {
            list,
            total: total[0].total,
            code: '001'
        }
    } else ctx.state.data = {
        code: '002'
    }
};